<?php

class myTestFunctional extends sfTestFunctional
{
  /*
  protected static $standardUser = null;

  public function click($name, $arguments = array(), $options = array())
  {
    $this->test()->info(sprintf('Click "%s"', $name));

    try
    {
      $click = parent::click($name, $arguments, $options);
      return $click;
    }
    catch (sfException $e)
    {
      $this->test()->fail($e->getMessage());
      return $this;
    }
  }

  public static function getStandardTestUser()
  {
    if (is_null(self::$standardUser))
    {
      self::$standardUser = usersFactory::createTestUser('testuser', 'testpass1', 'John', 'DoeDoe');
    }

    return self::$standardUser;
  }
  */

  public function signInUser($username, $password, $goto = '/')
  {
    self::$test->comment(sprintf('User "%s" signs in', $username));
    return $this->
      get('/')->
      click('Вход', array ( 'signin' => array (
        'username'       => $username,
        'password'       => $password,
      )))->
      with('response')->begin()->
        isStatusCode(302)->followRedirect()->
      end()->
      get($goto);
  }

  public function signOutUser()
  {
    return $this->
      click('Выход')->
      with('response')->isStatusCode(302)->
      with('request')->begin()->
        isParameter('module', 'sfGuardAuth')->
        isParameter('action', 'signout')->
      end();
  }
}

